<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>edit</title>
<link rel="stylesheet" type="text/css" href="resources/images/total.css" />
<script language="JavaScript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script language="JavaScript" src="resources/ckeditor/ckeditor.js"></script>
<script language="JavaScript" src="resources/ckeditor/adapters/jquery.js"></script>
<script language="JavaScript" src="resources/js/jquery.form.js"></script>
<script language="javascript">
var domain = '<{$domain}>';
// prepare the form when the DOM is ready 
$(document).ready(function() { 
    var options = { 
        target:        '#output2',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
        // other available options: 
        //url:		 url         // override for form's 'action' attribute 
        //type:      type        // 'get' or 'post', override for form's 'method' attribute 
        dataType:  'json',        // 'xml', 'script', or 'json' (expected server response type) 
        //clearForm: true        // clear all form fields after successful submit 
        //resetForm: true        // reset the form after successful submit 
 
        // $.ajax options can be used here too, for example: 
        //timeout:   3000 
    }; 
    // bind to the form's submit event 
    $('#article_form').submit(function() { 
		CKupdate();
        // inside event callbacks 'this' is the DOM element so we first 
        // wrap it in a jQuery object and then invoke ajaxSubmit 
        $(this).ajaxSubmit(options); 
        return false; 
    }); 
}); 

// pre-submit callback 
function showRequest(formData, jqForm, options) { 
    // formData is an array; here we use $.param to convert it to a string to display it 
    // but the form plugin does this for you automatically when it submits the data 
    //var queryString = $.param(formData); 
 
    // jqForm is a jQuery object encapsulating the form element.  To access the 
    // DOM element for the form do this: 
    // var formElement = jqForm[0]; 
 
    //alert('About to submit: \n\n' + queryString); 
 
 	//$('#editor1').val(CKEDITOR.instances.editor1.getData());
    // here we could return false to prevent the form from being submitted; 
    // returning anything other than false will allow the form submit to continue 
    return true;
}
 
// post-submit callback 
function showResponse(responseText, statusText, xhr, $form)  { 
    // for normal html responses, the first argument to the success callback 
    // is the XMLHttpRequest object's responseText property 
 
    // if the ajaxSubmit method was passed an Options Object with the dataType 
    // property set to 'xml' then the first argument to the success callback 
    // is the XMLHttpRequest object's responseXML property 
 
    // if the ajaxSubmit method was passed an Options Object with the dataType 
    // property set to 'json' then the first argument to the success callback 
    // is the json data object returned by the server 
 	
 	var status = responseText.status;
	if(status == 2){
		alert('输入文章名和文章内容');
	}else if(status == 1){
		alert('添加成功');
		window.location.href = domain + '?act=article.list';
	}
	return true;
}

function CKupdate(){
	for(instance in CKEDITOR.instances)
		CKEDITOR.instances[instance].updateElement();
}
</script>
</head>
<body class="idx_main">
<div class="main_cnt">
<!--<div class="edi_tt"><input type="submit" name="sub1" value="添加" onclick="alert('功能');"/></div>-->
<div class="r_cnt_t"><div class="r_cnt_lft">信息列表</div>
<!--<div class="r_cnt_rgt"><select name="sel1"><option>跳转分类到</option><option>信息添加到</option></select></div>-->
</div>
<div class="rgt_ctt">
<form name="article_form" id="article_form" action="<{$domain}>?act=article.insert" method="post">
<table class="edi_tab" width="100%" cellpadding="0" cellspacing="0">
<tr>
	<td width="9%" align="right">文章标题</td><td width="91%">&nbsp;&nbsp;&nbsp;&nbsp;<input class="edi_inp" type="text" name="title" style="width:400px;" /></td>
</tr>
<tr>
	<td align="right">文章作者</td><td>&nbsp;&nbsp;&nbsp;&nbsp;<input  class="edi_inp" type="text" name="author" /></td>
</tr>
<tr>
	<td align="right">文章来源</td><td>&nbsp;&nbsp;&nbsp;&nbsp;<input class="edi_inp"  type="text" name="source" /></td>
</tr>
<tr>
	<td align="right">是否推荐</td><td>&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="pick" value="1" /> 是　<input type="radio" name="pick" value="0" checked="checked" /> 否</td>
</tr>
<tr>
	<td align="right">信息正文</td>
	<td>&nbsp;&nbsp;&nbsp;&nbsp;<div class="ed_txt">
	<textarea name="content" id="editor1" rows="10" cols="80"></textarea>
	<script>
    	// Replace the <textarea id="editor1"> with a CKEditor
    	// instance, using default configuration.
        CKEDITOR.replace('editor1',{
    		filebrowserImageUploadUrl: '<{$domain}>?act=upload.img'
		});
	</script>
	</div></td>
</tr>

<tr>
	<td align="right">关键词</td><td width="91%">&nbsp;&nbsp;&nbsp;&nbsp;<input class="edi_inp" type="text" name="seo_keyword" style="width:400px;" />&nbsp;&nbsp;(英文,分割)</td>
</tr>

<tr>
	<td align="right">描述</td><td width="91%">&nbsp;&nbsp;&nbsp;&nbsp;<div class="ed_txt"><textarea name="seo_desc" id="seo_desc" rows="5" cols="80"></textarea></div></td>
</tr>

<tr><td colspan="2"><div class="ed_bt"><input class="e_inp" type="submit" name="sub1" value="提 交"/>　<input type="reset" name="reset" value="取 消" class="e_inp"/></div></td></tr>
</table>
</form>
</div>
</div>
</body>
</html>